
import { deleteItem } from '@/api/change-item'
import { Message } from 'element-ui'

// 作废数据
export function doDeleteItem() {
  if (this.ids.length < 1) {
    Message({
      message: '请选择需要作废的item。',
      type: 'error',
      duration: 3 * 1000
    })
  } else {
    this.$prompt('确认作废填写作废原因选择的 ' + this.ids.length + ' 条item信息?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      inputValidator: (value) => {
        if (value === null || value === '') {
          return false
        } else {
          return true
        }
      },
      inputErrorMessage: '请输入驳回原因'
      // type: 'warning'
    }).then((rejectMsg) => {
      this.loading = true
      deleteItem(this.ids, rejectMsg.value).then(() => {
        this.toQuery()
        Message({
          message: '操作成功。',
          type: 'success',
          duration: 3 * 1000
        })
        this.loading = false
      }, error => {
        console.log(error)
        this.loading = false
      })
    })
  }
}
